home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
misc
/
amag
/
12b92.lha
/
Tips & Tricks
/
Form. Strings (Assembler)
/
Format_Demo.asm
< prev
next >
Wrap
Assembly Source File
|
1992-11-02
|
3KB
|
92 lines
* * Name : FormatBsp.asm
* * Autor : Frank Enderle
* *
* * Assembler: A68K (Fish 521)
* * Linker : Blink (Fish 351)
RawDoFmt EQU -522
OpenLibrary EQU -552
CloseLibrary EQU -414
Write EQU -48
Output EQU -60
ExecBase EQU $4
Start: move.l ExecBase,a6
lea DosName,a1
moveq #0,d0
jsr OpenLibrary(a6) ; Dos öffnen
tst.l d0
beq 1$
move.l d0,DosBase
* Handle besorgen
move.l DosBase,a6
jsr Output(a6)
move.l d0,Handle
* Argumente
move.w #-1562,-(a7) ; 2 Bytes (WORD)
move.w #1625,-(a7) ; 2 Bytes (WORD)
move.w #'Z',-(a7) ; 2 Bytes (WORD)
pea String ; 4 Bytes (LONG)
move.l #$98CAF2,-(a7) ; + 4 Bytes (LONG)
move.l a7,a2 ; -----------------
; 14 Bytes
lea Format,a1 ; Formatstring
lea Buffer,a0 ; Puffer
bsr FormatStr ; String formatieren
lea 14(a7),a7 ; Stack um 14 Bytes ; korrigieren
lea Buffer,a0
bsr Print ; String ausgeben
move.l DosBase,a1
move.l ExecBase,a6
jsr CloseLibrary(a6) ; Dos schließen
1$: rts
;------------------------------------------------------------
; Print gibt einen String der in a0 übergeben wird im
; Output Handle aus. Der String muß mit einem NULL Byte enden
Print: movem.l d0-d7/a0-a6,-(a7)
move.l Handle,d1
move.l a0,d2
clr.l d3
1$: tst.b (a0)+
beq 2$
addq.l #1,d3
bra 1$
2$: move.l DosBase,a6
jsr Write(a6)
movem.l (a7)+,a0-a6/d0-d7
rts
;------------------------------------------------------------
; Format formatiert einen String wie es in C üblich ist
; (mit ein paar wenigen Ausnahmen)
; a0 -> Zeiger auf einen Puffer der den komplett
; formatierten String aufnehmen kann.
; a1 -> Zeiger auf den zu formatierenden String.
; a2 -> Zeiger auf eine Liste von Argumenten
FormatStr: movem.l d0-d7/a0-a6,-(a7)
move.l a0,a3
move.l a1,a0
move.l a2,a1
move.l #Routine,a2
move.l ExecBase,a6
jsr RawDoFmt(a6)
movem.l (a7)+,d0-d7/a0-a6
rts
Routine: move.b d0,(a3)+
rts
;----------------------------------------------------------
DosName: dc.b "dos.library",0
String: dc.b "Das ist ein Beispiel Text",0
Format: dc.b "Eine 32 Bit Hex Zahl: %08lx",10
dc.b "Ein String : %s",10
dc.b "Ein Buchstabe : %c",10
dc.b "Eine 16 Bit Hex Zahl: %x",10
dc.b "Eine 16 Bit Dez Zahl: %d",10,0
Buffer: ds.b 300
DosBase: dc.l 0
Handle: dc.l 0
END